<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">联营方</label>
                        <div class="layui-input-block">
                            <input type="text" name="lian_unit" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.id}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>




    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });


        setSouTableExport('项目经营情况表-联营');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_engin_jing_lian_list),where: {business:2}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(res.data.is_state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else {
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }

                }
                $("#state").html(state_str);

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'state_name', title: '项目状态'}
                ,{field:'name',title:'项目名称',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../engin/show.php?id='+d.id+'\')">'+d.name+'</span>';
                    }}
                ,{field: 'business_name', title: '经营方式'}
                ,{field: 'chanid_name', title: '所属机构'}
                ,{field: 'lian_unit', title: '联营方'}
                ,{field:'shimoney',title:'施工合同(元)',totalRow: true,align:'right',event: 'contract_shi',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shimoney)+'</span>';
                    }}
                ,{field:'lei_chan',title:'累计审定产值(元)',totalRow: true,align:'right',event: 'lei_chan',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_chan)+'</span>';
                    }}
                ,{field:'junjiemoney',title:'竣工结算金额(元)',totalRow: true,align:'right',event: 'engin_junjie',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.junjiemoney)+'</span>';
                    }}
                ,{field:'lei_piaokai',title:'累计开票(元)',totalRow: true,align:'right',event: 'piao_kai',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_piaokai)+'</span>';
                    }}
                ,{field:'kai_ratefee',title:'销项税(元)',totalRow: true,align:'right',event: 'piao_kai_hui',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.kai_ratefee)+'</span>';
                    }}
                ,{field:'lei_incomeengin',title:'项目收款 A(元)',totalRow: true,align:'right',event: 'income_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_incomeengin)+'</span>';
                    }}
                ,{field:'lei_incomeengingchk',title:'其中工程回款(元)',totalRow: true,align:'right',event: 'income_engin_gchk',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_incomeengingchk)+'</span>';
                    }}
                ,{field:'lei_payment_neikou',title:'内包扣款 B(元)',totalRow: true,align:'right',event: 'payment_neikou',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_neikou)+'</span>';
                    }}
                ,{field:'lei_payment_neifu',title:'内包付款 C(元)',totalRow: true,align:'right',event: 'payment_neifu',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_neifu)+'</span>';
                    }}
                ,{field:'lei_caihe',title:'采购合同总额(元)',totalRow: true,align:'right',event: 'contract_cai',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_caihe)+'</span>';
                    }}
                ,{field:'lei_jie',title:'供应商累计结算(元)',totalRow: true,align:'right',event: 'tong_pub',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_jie)+'</span>';
                    }}
                ,{field:'lei_payment_engin',title:'供应商累计付款 D(元)',totalRow: true,align:'right',event: 'payment_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_engin)+'</span>';
                    }}
                ,{field:'lei_payment_bao',title:'项目费用报销 E(元)',totalRow: true,align:'right',event: 'payment_bao',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_bao)+'</span>';
                    }}
                ,{field:'lei_piaoshou',title:'累计收票(元)',totalRow: true,align:'right',event: 'piao_shou',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_piaoshou)+'</span>';
                    }}
                ,{field:'lei_shou_jin',title:'进项税(元)',totalRow: true,align:'right',event: 'piao_shou_hui',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_shou_jin)+'</span>';
                    }}
                ,{field:'lei_balance',title:'项目余额 A-B-C-D-E(元)',totalRow: true,align:'right',templet: function(d){
                        return '<span class="">'+parseFormatNum(d.lei_balance)+'</span>';
                    }}
                ,{field:'zhirate',title:'质保金比例',event: 'contract_shi2',templet: function(d){
                        return '<span class="colorlan">'+(d.zhirate)+'</span>';
                    }}
                ,{field:'zhifee',title:'质保金金额(元)',totalRow: true,align:'right',templet: function(d){
                        return '<span class="">'+parseFormatNum(d.zhifee)+'</span>';
                    }}
                ,{field:'zhinum',title:'质保期',templet: function(d){
                        return '<span class="">'+(d.zhinum)+'</span>';
                    }}
                ,{field:'zhidt',title:'质保金到期日期',templet: function(d){
                        return '<span class="">'+(d.zhidt)+'</span>';
                    }}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'contract_shi'){
                openNavPage('查看施工合同信息','contract_shi/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'lei_chan'){
                openNavPage('查看产值填报信息','engin_chan/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'engin_junjie'){
                openNavPage('查看竣工结算信息','engin_junjie/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'piao_kai'){
                openNavPage('查看开票信息','piao_kai/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'piao_kai_hui'){
                openNavPage('查看开票明细信息','piao_kai_hui/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'income_engin'){
                openNavPage('查看项目收款信息','income_engin/index.php?status=1&enginid='+data.id+'&budname='+encodeURIComponent('工程款垫资款'));
            }
            if(obj.event === 'income_engin_gchk'){
                openNavPage('查看项目收款信息','income_engin/index.php?status=1&enginid='+data.id+'&budname='+encodeURIComponent('工程款'));
            }
            if(obj.event === 'payment_neikou'){
                openNavPage('查看内包扣款信息','payment_neikou/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'payment_neifu'){
                openNavPage('查看内包付款信息','payment_neifu/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'contract_cai'){
                openNavPage('查看采购合同信息','contract_cai/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'tong_pub'){
                openPage('../tong_pub/gonglei.php?enginid='+data.id, '80%', '80%');
            }
            if(obj.event === 'payment_engin'){
                openNavPage('查看供应商累计付款信息','payment_engin/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'payment_bao'){
                openNavPage('查看项目费用报销信息','payment_bao/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'piao_shou'){
                openNavPage('查看收票信息','piao_shou/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'piao_shou_hui'){
                openNavPage('查看收票明细信息','piao_shou_hui/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'contract_shi2'){
                openPage('../contract_shi/show.php?id='+data.shiid, '80%', '80%');
            }


        });
        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, id){
        openPage('show.php?id='+id);
    }


</script>
</body>
</html>
